home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / misc / hwgrcs10i.lha / PATCH8TO10 / InstallPatch < prev    next >
Encoding:
Text File  |  1994-06-06  |  4.6 KB  |  184 lines

  1. /*------------------------------------------------------------------------*/
  2. /* An ARexx script to install a patch with handlepatch
  3.  
  4.     (C)1994 by Heinz Wrobel, for Joan Thuesen
  5.  
  6. */
  7. /*------------------------------------------------------------------------*/
  8. options failat 10
  9.  
  10. /*------------------------------------------------------------------------*/
  11. vers = '$VER: InstallPatch 37.0 (05.06.94)'
  12. title = trim(substr(vers, 7) "(C)1994 Heinz Wrobel, For Joan Thuesen")
  13. cls = '1b'x || '[0;0H' || '1b'x || '[J'
  14.  
  15. unarc = 'lha -a -q -r x'
  16. tmpdir = 'T:PatchTemp'
  17. pinfo = '.patchinfo'
  18.  
  19. /*------------------------------------------------------------------------*/
  20. options results
  21. address command
  22.  
  23. if ~show('L', 'rexxsupport.library') then do
  24.     if ~addlib('rexxsupport.library', 0, -30) then do
  25.         say 'Please install the rexxsupport.library in your LIBS: directory'
  26.         exit(20)
  27.     end
  28. end
  29.  
  30. /*------------------------------------------------------------------------*/
  31. if ~exists(pinfo) then do
  32.     say "The file" pinfo "is missing!"
  33.     exit(20)
  34. end
  35.  
  36. call writech('STDOUT', cls)
  37. say ""
  38. say title
  39. say copies("=", length(title))
  40.  
  41. say ""
  42.  
  43. if (open('i', pinfo, 'R')) then do
  44.     patchdesc    = trim(readln('i'))
  45.     srcarcname   = trim(readln('i'))
  46.     srcfullname  = trim(readln('i'))
  47.     destfullname = trim(readln('i'))
  48.  
  49.     say "'" || patchdesc ||"'"
  50.     say ""
  51.  
  52.     do while ~eof('i')
  53.         line = readln('i')
  54.         i = index(line, '%SA%')
  55.         do while i > 0
  56.             line = left(line, i - 1) || srcarcname || substr(line, i + 4)
  57.             i = index(line, '%SA%')
  58.         end
  59.  
  60.         i = index(line, '%SF%')
  61.         do while i > 0
  62.             line = left(line, i - 1) || srcfullname || substr(line, i + 4)
  63.             i = index(line, '%SF%')
  64.         end
  65.  
  66.         i = index(line, '%DF%')
  67.         do while i > 0
  68.             line = left(line, i - 1) || destfullname || substr(line, i + 4)
  69.             i = index(line, '%DF%')
  70.         end
  71.  
  72.         say line
  73.     end
  74.     call close('i')
  75.  
  76.     call writech('STDOUT', 'Press <RETURN> after reading: ')
  77.     pull dummy
  78.     say ""
  79. end
  80. else
  81. do
  82.     say "Could not open" pinfo
  83.     exit(20)
  84. end
  85.  
  86. /*------------------------------------------------------------------------*/
  87. call writech('STDOUT', cls)
  88. say ""
  89. say title
  90. say copies("=", length(title))
  91.  
  92. say ""
  93. say "'" || patchdesc ||"'"
  94. say ""
  95.  
  96. say "Please specify the full pathname for the source archive" 
  97. say "named '" || srcarcname || "' or the base directory name that"
  98. say "contains the unchanged archive contents in unpacked form." 
  99. say ""
  100. say "If the archive can't be found in the specified directory, it is"
  101. say "assumed to be the base of the unpacked archive contents."
  102. say ""
  103. call writech('STDOUT', 'Your input: ')
  104. pull SourceArc
  105. SourceArc = trim(SourceArc)
  106.  
  107. if ~exists(SourceArc) then do
  108.     say "Could not find" SourceArc
  109.     exit(20)
  110. end
  111.  
  112. say ""
  113. say "Now specify where to put the patched tree (the destination)."
  114. say "Source and destination may not be the same!"
  115. say ""
  116. call writech('STDOUT', 'Your input: ')
  117. pull DestDir
  118. DestDir = trim(DestDir)
  119.  
  120. if(SourceArc = DestDir) then do
  121.     say ""
  122.     say "I told you! You may not have the same source and destination!"
  123.     exit(20)
  124. end
  125.  
  126. if ~exists(DestDir) then do
  127.     say ""
  128.     say "Creating" DestDir "..."
  129.     call makedir(DestDir)
  130. end
  131.  
  132. od = pragma(D, SourceArc)
  133. if exists(srcarcname) then do
  134.     say ""
  135.     say "Unpacking source archive to" tmpdir "..."
  136.     if ~exists(tmpdir) then do
  137.         call makedir(tmpdir)
  138.     end
  139.     olddir = pragma(D, tmpdir)
  140.     address command 'delete >NIL: #? all quiet force'
  141.     address command unarc mkfilename(SourceArc,srcarcname)
  142.     call pragma(D, olddir)
  143.     SourceArc = tmpdir
  144. end
  145. call pragma(D, od)
  146.  
  147. /*------------------------------------------------------------------------*/
  148. say ""
  149. say "Creating patch in" DestDir "..."
  150. say ""
  151. address command 'handlepatch quiet patchdir "" from' SourceArc 'to' DestDir
  152.  
  153. if (SourceArc = tmpdir) then do
  154.     address command 'delete >NIL:' tmpdir 'all quiet force'
  155. end
  156.  
  157. say "The patched files are now in" DestDir || ". Please copy them"
  158. say "to their final destination."
  159.  
  160. exit(0)
  161.  
  162. /*------------------------------------------------------------------------*/
  163. /* Put together a file name with the correct separators */
  164. mkfilename: procedure
  165.             parse arg pathpart,file
  166.  
  167.     ot = trace(off)
  168.     if length(pathpart) > 0 then do
  169.         c = right(pathpart, 1)
  170.         if c ~= '/' & c ~= ':' then do
  171.             pathpart = pathpart || '/'
  172.         end
  173.  
  174.         file = pathpart || file
  175.     end
  176.     ot = trace(ot)
  177.  
  178.     return(file)
  179.  
  180. /*------------------------------------------------------------------------*/
  181.  
  182. /* Ende des Quelltextes */
  183.  
  184.